package minidb.test; 

import minidb.record.*;
import minidb.type.*;
import minidb.file.*;
import minidb.index.*;
import static minidb.type.Const.*;

public class Main {

	/**
	 * @param argv
	 */
	public static void main(String argv[]){
		IntConstant a = new IntConstant(10);
		DoubleConstant b = new DoubleConstant(11);
		System.out.println(a.compareTo(b));
		java.util.HashSet<String> hash = new java.util.HashSet<String>();
		String s = "aa";
		String ss = "aa";
		System.out.println(s.hashCode());
		System.out.println(ss.hashCode());
		for(int i = 0; i < 30000000; i++){
			hash.add(String.valueOf(i));
			if(i%10000==0)
				System.out.println(i);
		}
		/*minidb.file.FileMgr fMgr = null;
		try{
			fMgr = new FileMgr("d:\\a.zcx");
			dbFile(fMgr);
			TablePage table = new TablePage();
			tablePage(table);
			TableInfo tableInfo = table.get("table1");
			RecordPage rec = new RecordPage(tableInfo);
			Record record;
			rec.rewind();
			while(true){
				record = rec.get();
				System.out.println(record.get(1).toVal()+" "+record.get(2).toVal()+" "
						+record.get(3).toVal()+" "+record.get(4).toVal());
				rec.next();
				
			}*/
			/*Schema schema = new Schema();
			fieldinfo finfo;
			finfo = new fieldinfo("name",TYPE.STRING,11,0);
			schema.add(finfo);
			finfo = new fieldinfo("id",TYPE.INT,INT_SIZE,11);
			schema.add(finfo);
			for(int i = 1; i <= 10; i++){
				table.addTable(new TableInfo(schema,"table"+i,0,0));
			}
			table.deleteTable("table7");
			for(int i = 0; i < 10; i++){
				table.deleteTable(new TableInfo(schema,"table"+i,0,0));
			}*/
			/*TableInfo tableInfo = table.get("table1");
			RecordPage rec = new RecordPage(tableInfo);
			Record record = new Record(tableInfo.recordlength(),rec.fieldinfo());
			bTreeIndex btree = new bTreeIndex(tableInfo, rec);
			btree.CreatIndex("id");
			for(int i = 0; i < 10000; i++){
				record.putInt(2, i);
				record.putString(1, "happy"+i);
				rec.Insert(record);
			}
			rec.rewind();
			while(rec.next()){
				record = rec.get();
				System.out.println(record.getString(1));
			}
			//bTreeIndex btree = new bTreeIndex(tableInfo, rec);
			//btree.DeleteIndex("id");
			//btree.delete(new IntConstant(99));
			for(int i = 0; i < 100; i++){
				if(i == 61)
					System.out.println(i);
				btree.delete(new IntConstant(i));
				
				System.out.println(i);
			}
			Buffer buf = bufpool.pin(tableInfo.indexPage());
			int pageNum  = dbFile.allocPage();
			buf.putInt(INT_SIZE*4, pageNum);
			buf.putString(INT_SIZE*5, "id");
			bufpool.unpin(buf);
			buf = bufpool.pin(pageNum);
			buf.putInt(INT_SIZE * 5, 1);
			bufpool.unpin(buf);
			bTreePage btree = new bTreePage(tableInfo.indexPage(), rec, tableInfo);
			//btree.beforeFirst(new IntConstant(3));
			//System.out.println(btree.getRid().toString());
			for(int i = 0; i < 1024; i++){
				//if(i == 186)
					System.out.println(i);
				record.putInt(2, i);
				record.putString(1, "happy"+i);
				btree.insert(record.get(2), rec.Insert(record));
			}
			btree.beforeFirst(new IntConstant(100));
			System.out.println(btree.getRid().toString());
			rec.rewind();
			while((record=rec.get())!=null){
				record.putString(1, "zcx");
				//System.out.println("zcx");
				rec.update(record);
				if(!rec.next())
					break;
			}
			fMgr.close();
		}catch(Exception e){
			if(fMgr!=null)
				fMgr.close();
			System.out.println("Exception  "+e.toString());
		}*/

	}
}
